# Contributor: Bradley J Chambers <brad.chambers@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=fgt
pkgver=0.4.9
pkgrel=4
pkgdesc="C++ library for fast Gauss transforms."
url="https://github.com/gadomski/fgt"
arch="all"
license="LGPL-2.0-or-later"
makedepends="cmake eigen-dev samurai"
subpackages="$pkgname-dev"
source="https://github.com/gadomski/fgt/archive/v$pkgver/fgt-v$pkgver.tar.gz
	0001-Stop-forcing-static-builds.patch
	cxx17.patch
	"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DWITH_TESTS=ON \
		-DBUILD_SHARED_LIBS=ON
	cmake --build build
}

check() {
	cd build

	case "$CARCH" in
		s390x) tests="cluster" ;;
	esac

	local skipped_tests="("

	for test in $tests; do
		skipped_tests="$skipped_tests|$test"
	done

	skipped_tests="$skipped_tests)"

	# CMake seems to exclude _all_ tests if we only pass "()" for some reason
	if [ "$skipped_tests" = "()" ]; then
		CTEST_OUTPUT_ON_FAILURE=TRUE ctest
	else
		CTEST_OUTPUT_ON_FAILURE=TRUE ctest -E "$skipped_tests"
	fi
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
06d850aee0144be05741ff0977a7a194e467d3666015f835acdde9ecfdfdd2ef52974f7c95a034cc1c791a58e398664de47e42ca8bcbcc1dddd8f0aaa520cc80  fgt-v0.4.9.tar.gz
8c6c673339abe4bbfcb7c2609af7456c47e12c6e27681296fef2ddd465ac92dbf1155f447d34a3e592b6cfb01de72954351ad15b7b369376806831065bbb3dec  0001-Stop-forcing-static-builds.patch
436a1abed0536904c896ab077bd49a647ea07f02d3175723655f4a0992b2968d0cb566b288570e150bb74c25eeb13a7c0c249a46c23427d2b53e8f1e3b484c62  cxx17.patch
"
